<html>
 <head>
  <meta charset="UTF-8">
 </head>
 <body>
  <h1 data-lake-id="bLM6O" id="bLM6O"><span data-lake-id="u5f1ec744" id="u5f1ec744">典型回答</span></h1>
  <p data-lake-id="u65a57fe1" id="u65a57fe1"><br></p>
  <p data-lake-id="u12a77423" id="u12a77423"><span data-lake-id="ud195623c" id="ud195623c">有一堆桃子，猴子第一天吃了一半加一个，第二天又吃了一半加一个，第三天又吃了一半加一个，以此类推，到第10天时只剩下一个桃子，问这堆桃子原来有多少个？</span></p>
  <p data-lake-id="u86870546" id="u86870546"><span data-lake-id="u2c6d6562" id="u2c6d6562">​</span><br></p>
  <p data-lake-id="uad615a69" id="uad615a69"><span data-lake-id="u18f903b2" id="u18f903b2">这是一道经典的编程题目。</span></p>
  <p data-lake-id="ud3b28a65" id="ud3b28a65"><span data-lake-id="u48ce5c1c" id="u48ce5c1c">​</span><br></p>
  <p data-lake-id="ub902b5b4" id="ub902b5b4"><span data-lake-id="u6f2d717c" id="u6f2d717c">&gt;猴子每天都吃了剩下桃子的一半再加一个。如果我们从第10天开始反推到第1天，计算过程如下：</span></p>
  <ul list="uc8a88a29">
   <li fid="u40a9b34f" data-lake-id="u505b3756" id="u505b3756" data-lake-index-type="true"><span data-lake-id="u9804cc0e" id="u9804cc0e">第10天</span><span data-lake-id="u3f47aa41" id="u3f47aa41">：剩下1个桃子。</span></li>
   <li fid="u40a9b34f" data-lake-id="u5b06c1ef" id="u5b06c1ef" data-lake-index-type="true"><span data-lake-id="udd8dc073" id="udd8dc073">第9天</span><span data-lake-id="u3d81a4d0" id="u3d81a4d0">：第10天之前，桃子的数量是（1 + 1）* 2 = 4个。</span></li>
   <li fid="u40a9b34f" data-lake-id="u5120461b" id="u5120461b" data-lake-index-type="true"><span data-lake-id="ub02fcef7" id="ub02fcef7">第8天</span><span data-lake-id="ucd3af41b" id="ucd3af41b">：第9天之前，桃子的数量是（4 + 1）* 2 = 10个。</span></li>
   <li fid="u40a9b34f" data-lake-id="uc505de4c" id="uc505de4c" data-lake-index-type="true"><span data-lake-id="u5591a0a7" id="u5591a0a7">第7天</span><span data-lake-id="ubc6d5b00" id="ubc6d5b00">：第8天之前，桃子的数量是（10 + 1）* 2 = 22个。</span></li>
   <li fid="u40a9b34f" data-lake-id="ub213ea63" id="ub213ea63" data-lake-index-type="true"><span data-lake-id="ua8d5c507" id="ua8d5c507">第6天</span><span data-lake-id="u1c4317f6" id="u1c4317f6">：第7天之前，桃子的数量是（22 + 1）* 2 = 46个。</span></li>
   <li fid="u40a9b34f" data-lake-id="u3074dfbb" id="u3074dfbb" data-lake-index-type="true"><span data-lake-id="u09aaadca" id="u09aaadca">第5天</span><span data-lake-id="uac24448a" id="uac24448a">：第6天之前，桃子的数量是（46 + 1）* 2 = 94个。</span></li>
   <li fid="u40a9b34f" data-lake-id="udd05772d" id="udd05772d" data-lake-index-type="true"><span data-lake-id="u895d3177" id="u895d3177">第4天</span><span data-lake-id="u1ead8aff" id="u1ead8aff">：第5天之前，桃子的数量是（94 + 1）* 2 = 190个。</span></li>
   <li fid="u40a9b34f" data-lake-id="u93e54361" id="u93e54361" data-lake-index-type="true"><span data-lake-id="uf2a78ec4" id="uf2a78ec4">第3天</span><span data-lake-id="ua139dd6d" id="ua139dd6d">：第4天之前，桃子的数量是（190 + 1）* 2 = 382个。</span></li>
   <li fid="u40a9b34f" data-lake-id="u068cac57" id="u068cac57" data-lake-index-type="true"><span data-lake-id="u4500ea50" id="u4500ea50">第2天</span><span data-lake-id="u006f0ecc" id="u006f0ecc">：第3天之前，桃子的数量是（382 + 1）* 2 = 766个。</span></li>
   <li fid="u40a9b34f" data-lake-id="u3a853805" id="u3a853805" data-lake-index-type="true"><span data-lake-id="u3d4d0d30" id="u3d4d0d30">第1天</span><span data-lake-id="u527028ac" id="u527028ac">：第2天之前，桃子的数量是（766 + 1）* 2 = 1534个。</span></li>
  </ul>
  <p data-lake-id="u1de9ab63" id="u1de9ab63"><span data-lake-id="uea849b7a" id="uea849b7a">因此，最开始这堆桃子共有1534个。</span></p>
  <p data-lake-id="u72b04a51" id="u72b04a51"><span data-lake-id="ufb6dea7b" id="ufb6dea7b">​</span><br></p>
  <p data-lake-id="ueb73b1a9" id="ueb73b1a9"><span data-lake-id="u487bd936" id="u487bd936">那么代码如下：</span></p>
  <pre lang="java"><code>
public static void main(String[] args) {
    int total = 1;
    for(int i=10; i&gt;1; i--){
        total = (total+1)&lt;&lt;1;
    }
    System.out.println(total);
}
</code></pre>
  <p data-lake-id="ua94b8378" id="ua94b8378"><span data-lake-id="u02cdbb1f" id="u02cdbb1f" class="lake-fontsize-12" style="color: rgb(55, 65, 81); background-color: rgb(247, 247, 248)">​</span><br></p>
  <blockquote data-lake-id="u8b64e9a3" id="u8b64e9a3">
   <p data-lake-id="ue9cc0579" id="ue9cc0579"><span data-lake-id="u680f9fa8" id="u680f9fa8" class="lake-fontsize-12">这里的&lt;&lt; 是向左移一位，在二进制中向左移一位，在十进制中就是*2的意思。</span></p>
  </blockquote>
  <p data-lake-id="u12c74a2e" id="u12c74a2e"><br></p>
  <p data-lake-id="u9d0a6d7a" id="u9d0a6d7a"><span data-lake-id="ua3015f88" id="ua3015f88">最终得到1534</span></p>
 </body>
</html>